<%--
  Created by IntelliJ IDEA.
  User: xianfei
  Date: 15-6-25
  Time: 上午10:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>周次管理</title>
    <script>
        $(function () {
            change();

            $("#selectAll").on("click", function () {
                if ($(this).is(":checked")) {
                    $(":checkbox").prop("checked", "true");
                } else {
                    $(":checkbox").removeAttr("checked");
                }
            });
        })

        function change() {
            var houseInfoGuid = $("#houseInfo").val();
            $.ajax({
                url: '/house_week/find_house_week/' + houseInfoGuid,
                type: 'get',
                dataType: 'json',
                success: function (data) {
                    $(".table tbody").empty();
                    $(".table tbody").append(data);
                }, error: function () {
                    alert('error');
                }
            })
        }

        function delHouseWeek() {
            var checkboxs = $(":checkbox").not("#selectAll");
            var guids = '';
            for (var i = 0; i < checkboxs.length; i++) {
                if (checkboxs.eq(i).is(":checked")) {
                    guids += i == checkboxs.length - 1 ? checkboxs.eq(i).val() : checkboxs.eq(i).val() + ',';
                }
            }
            $.ajax({
                url: '/house_week/del/' + guids,
                type: 'get',
                dataType: 'text',
                success: function (data) {
                    location.reload();
                }, error: function () {
                    alert('error');
                }

            })
        }

        function update(guid) {
            var houseInfoName = $("#houseInfo option:selected").html();
            location.href = "/house_week/modify/" + guid ;
//            $.ajax({
//                url: '/house_week/modify/' + guid,
//                type: 'get',
//                dataType: 'text',
//                success: function (data) {
//
//                }
//
//            })
        }

        function deletehouseweek(weekguid){
            $.ajax({
                url: '/house_week/del/'+weekguid,
                type: 'get',
                dataType: 'text',
                success: function () {
                    location.reload();
                }
            })
        }

    </script>
</head>
<body>
<div>
    <select id="houseInfo" onchange="change()" class="col-lg-4" style="height: 40px">
        <c:forEach items="${houseInfoDTOs}" var="list">
            <option value="${list.guid}">${list.name}</option>
        </c:forEach>
    </select>

    <table class="table table-striped">
        <thead>
        <th>#</th>
        <th>周次名称</th>
        <th>价格</th>
        <th>总量</th>
        <th>已销售</th>
        <th>描述</th>
        <th>操作</th>
        </thead>
        <tbody>

        </tbody>
    </table>
</div>
</body>
</html>